CXX    = g++
CFLAGS = -g -O2 -fPIC -Wall -Wno-write-strings $(shell root-config --cflags)
LIBS   = $(shell root-config --glibs) -lFoam -lRooFit -lRooFitCore -lMinuit -lboost_regex -lboost_thread

H      = $(shell ls | grep .h)
SRC    = $(shell ls | grep .cxx)
OBJ    = $(SRC:.cxx=.o)

all: $(H) $(OBJ)
	cd FitMethods && make
	cd EfficCalcMethods && make
	$(CXX) $(CFLAGS) $(LIBS) -o analyze.exe FitMethods/*.o EfficCalcMethods/*.o *.o
	mv *.exe ..

%.o: %.cxx $(H)
	$(CXX) $(CFLAGS) -c $< -o $@

Analysis: $(OBJ) $(H)

clean:
	cd FitMethods && make clean
	cd EfficCalcMethods && make clean
	rm -rf *.o *~

.PHONY: clean Analysis all
